#include <nxos.h>
#include <wm/window.h>
#include "wm.h"

NX_Size WM_Dispatch(NX_IpcMsg *ipc_msg);

NX_PRIVATE void WM_IpcHandler(NX_IpcMsg *ipc_msg)
{
    NX_Size ret = WM_Dispatch(ipc_msg);
    NX_IpcReturn(ret);
}

int main(int argc, char **argv)
{
    NX_Error err;
    if (NX_IpcBind(NX_WINDOW_IPC_NAME, WM_IpcHandler, 32) < 0)
    {
        NX_Printf("Window manager was registered!\n");
        return -1;
    }

    err = WM_WindowSystemInit();
    if (err != NX_EOK)
    {
        NX_Printf("Window manager init failed state %s !\n", NX_ErrorToString(err));
    }
    return 0;
}
